<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/jsp/commons/taglibs.jsp"%>
<style>
#single table th {
	vertical-align: top;
}
</style>
<ul class="nav nav-tabs tab tBlock">
	<li class="active">
		<a deny="not" class="nFocus" href="#single" data-toggle="tab">
			<i class="icon-envelope"></i>
			短信常规设置
		</a>
	</li>
</ul>

<div class="tab-content" style="margin-top: -20px; padding: 10px;">
	<div class="tab-pane active" id="single">
		<form id="smsForm" class="well form-inline" action="${ctx }/sms/send" method="post">
			<table class="table table-striped table-bordered table-condensed">
				<tr>
					<th class="span2">短信接收服务</th>
					<td>
						<label class="radio">
							<input type="radio" ${rcIsRun ? 'checked':'' } name="rcIsRun" value="1" />
							启动
						</label>
						<label class="radio">
							<input type="radio" ${rcIsRun ? '':'checked' } name="rcIsRun" value="0" />
							停止
						</label>
					</td>
					<td>
						<button type="button" id="reciveServer" class="btn btn-small btn-danger">确定</button>
					</td>
				</tr>
				<tr>
					<th>短信发送服务</th>
					<td>
						<label class="radio">
							<input type="radio" ${smsIsRun ? 'checked':'' } name="smsIsRun" value="1" />
							启动
						</label>
						<label class="radio">
							<input type="radio" ${smsIsRun ? '':'checked' } name="smsIsRun" value="0" />
							停止
						</label>
					</td>
					<td>
						<button type="button" id="sendServer" class="btn btn-small btn-danger">确定</button>
					</td>
				<tr>
					<th>短信自动回复服务</th>
					<td>
						<label class="radio">
							<input type="radio" ${rpIsRun ? 'checked':'' } name="rpIsRun" value="1" />
							启动
						</label>
						<label class="radio">
							<input type="radio" ${rpIsRun ? '':'checked' } name="rpIsRun" value="0" />
							停止
						</label>
					</td>
					<td>
						<button type="button" id="replyServer" class="btn btn-small btn-danger">确定</button>
					</td>
				</tr>
			</table>
		</form>
	</div>
</div>

<script>
	$(function() {
		$("#reciveServer").click(function() {
			if ($("[name=rcIsRun]:checked").val() == 1) {
				$.post("${ctx}/sms/startRecive", function(data) {
					if (data) {
						msgAlert.show("短信接收服务已启动！");
					} else {
						msgAlert.show("服务异常，请联系系统管理！");
					}
				}, 'json');
			} else {
				$.post("${ctx}/sms/stopRecive", function(data) {
					if (data) {
						msgAlert.show("短信接收服务已停止！");
					} else {
						msgAlert.show("服务异常，请联系系统管理！");
					}
				}, 'json');
			}
		});
		$("#replyServer").click(function() {
			if ($("[name=rpIsRun]:checked").val() == 1) {
				$.post("${ctx}/sms/startReply", function(data) {
					if (data) {
						msgAlert.show("短信自动回复服务已启动！");
					} else {
						msgAlert.show("服务异常，请联系系统管理！");
					}
				}, 'json');
			} else {
				$.post("${ctx}/sms/stopReply", function(data) {
					if (data) {
						msgAlert.show("短信自动回复服务已停止！");
					} else {
						msgAlert.show("服务异常，请联系系统管理！");
					}
				}, 'json');
			}
		});
		$("#sendServer").click(function() {
			if ($("[name=smsIsRun]:checked").val() == 1) {
				$.post("${ctx}/sms/startSend", function(data) {
					if (data) {
						msgAlert.show("短信发送服务已启动！");
					} else {
						msgAlert.show("服务异常，请联系系统管理！");
					}
				}, 'json');
			} else {
				$.post("${ctx}/sms/stopSend", function(data) {
					if (data) {
						msgAlert.show("短信发送服务已停止！");
					} else {
						msgAlert.show("服务异常，请联系系统管理！");
					}
				}, 'json');
			}
		});
	});
</script>
